package bocchi.power;

import bocchi.BocchiCore;
import bocchi.base.BaseCustomPower;
import com.megacrit.cardcrawl.actions.common.ReducePowerAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.cards.DamageInfo.DamageType;
import com.megacrit.cardcrawl.core.AbstractCreature;

public class OverdrivePower extends BaseCustomPower {
    private static final String RAW_ID = "Overdrive";
    public static final String GAME_ID = BocchiCore.getGameID(RAW_ID);

    public OverdrivePower(AbstractCreature owner, int amount) {
        super(RAW_ID, PowerType.BUFF, owner, amount);
    }

    @Override
    public void updateDescription() {
        description = String.format(powerStrings.DESCRIPTIONS[0], amount * 25);
    }

    @Override
    public float atDamageFinalGive(float damage, DamageType type) {
        if (type == DamageType.NORMAL) {
            damage *= (1 + amount * 0.25F);
            return damage;
        }

        return damage;
    }

    @Override
    public void onAttack(DamageInfo info, int damageAmount, AbstractCreature target) {
        if (info.type == DamageType.NORMAL) {
            flash();
            addToTop(new ReducePowerAction(owner, owner, this, 1));
        }
    }

    @Override
    public void stackPower(int stackAmount) {
        super.stackPower(stackAmount);

        if (amount > 4) {
            amount = 4;
        }
    }
}
